﻿namespace Silverlight.Treemap.Example
{
    using System.Windows.Data;

    public partial class Page
    {
        public Page()
        {
            this.InitializeComponent();

            var driveItem = new DriveItem
                                {
                                        Name = "Root",
                                        ChildDriveItems =
                                                {
                                                        new DriveItem
                                                            {
                                                                    Name = "FOLDER 1",
                                                                    Size = 10,
                                                                    ChildDriveItems =
                                                                            {
                                                                                    new DriveItem {Name = "File 1", Size = 6},
                                                                                    new DriveItem {Name = "File 2", Size = 8},
                                                                                    new DriveItem {Name = "File 3", Size = 12},
                                                                                    new DriveItem {Name = "File 4", Size = 14}
                                                                            }
                                                            },
                                                        new DriveItem
                                                            {
                                                                    Name = "FOLDER 2",
                                                                    Size = 30,
                                                                    ChildDriveItems =
                                                                            {
                                                                                    new DriveItem {Name = "File 1", Size = 19},
                                                                                    new DriveItem
                                                                                        {
                                                                                                Name = "Folder 2 - FOLDER 2A",
                                                                                                Size = 11,
                                                                                                ChildDriveItems =
                                                                                                        {
                                                                                                                new DriveItem {Name = "File 1", Size = 7},
                                                                                                                new DriveItem {Name = "File 2", Size = 23}
                                                                                                        }
                                                                                        },
                                                                                    new DriveItem
                                                                                        {
                                                                                                Name = "Folder 3 - FOLDER 3A",
                                                                                                Size = 32,
                                                                                                ChildDriveItems =
                                                                                                        {
                                                                                                                new DriveItem {Name = "File 1", Size = 8},
                                                                                                                new DriveItem {Name = "File 2", Size = 16}
                                                                                                        }
                                                                                        }
                                                                            }
                                                            },
                                                        new DriveItem
                                                            {
                                                                    Name = "FOLDER 4",
                                                                    Size = 30,
                                                                    ChildDriveItems =
                                                                            {
                                                                                    new DriveItem {Name = "File 1", Size = 19},
                                                                                    new DriveItem
                                                                                        {
                                                                                                Name = "Folder 5 - FOLDER 5A",
                                                                                                Size = 11,
                                                                                                ChildDriveItems =
                                                                                                        {
                                                                                                                new DriveItem {Name = "File 1", Size = 7},
                                                                                                                new DriveItem {Name = "File 2", Size = 23}
                                                                                                        }
                                                                                        },
                                                                                    new DriveItem
                                                                                        {
                                                                                                Name = "Folder 6 - FOLDER 6A",
                                                                                                Size = 32,
                                                                                                ChildDriveItems =
                                                                                                        {
                                                                                                                new DriveItem {Name = "File 1", Size = 8},
                                                                                                                new DriveItem {Name = "File 2", Size = 16}
                                                                                                        }
                                                                                        }
                                                                            }
                                                            },
                                                        new DriveItem
                                                            {
                                                                    Name = "FOLDER 7",
                                                                    Size = 30,
                                                                    ChildDriveItems =
                                                                            {
                                                                                    new DriveItem {Name = "File 1", Size = 19},
                                                                                    new DriveItem
                                                                                        {
                                                                                                Name = "Folder 8 - FOLDER 8A",
                                                                                                Size = 11,
                                                                                                ChildDriveItems =
                                                                                                        {
                                                                                                                new DriveItem {Name = "File 1", Size = 7},
                                                                                                                new DriveItem {Name = "File 2", Size = 23}
                                                                                                        }
                                                                                        },
                                                                                    new DriveItem
                                                                                        {
                                                                                                Name = "Folder 9 - FOLDER 9A",
                                                                                                Size = 32,
                                                                                                ChildDriveItems =
                                                                                                        {
                                                                                                                new DriveItem {Name = "File 1", Size = 8},
                                                                                                                new DriveItem {Name = "File 2", Size = 16}
                                                                                                        }
                                                                                        }
                                                                            }
                                                            }
                                                }
                                };

            this.chart.IndependentValueBinding = new Binding("Name");
            this.chart.DependentValueBinding = new Binding("Size");
            this.chart.ChildItemsSourceBinding = new Binding("ChildDriveItems");
            this.chart.ItemsSource = driveItem.ChildDriveItems;
        }
    }
}